package de.hauschild.jchronology.data1;

import java.util.Date;

import de.hauschild.jchronology.Duration;

public class ChronologyEntry {

  private Date startTime;
  private Date endTime;
  private Duration breakDuration;
  private Duration targetDuration;

  public Duration getBreakDuration() {
    return breakDuration;
  }

  public Duration getDuration() {
    if (startTime == null || endTime == null || breakDuration == null || targetDuration == null) {
      return null;
    }
    return new Duration(endTime.getTime() - startTime.getTime() - breakDuration.getDuration());
  }

  public Date getEndTime() {
    return endTime;
  }

  public Duration getResultDuration() {
    if (startTime == null || endTime == null || breakDuration == null || targetDuration == null) {
      return null;
    }
    return new Duration(endTime.getTime() - startTime.getTime() - targetDuration.getDuration()
        - breakDuration.getDuration());
  }

  public Date getStartTime() {
    return startTime;
  }

  public Duration getTargetDuration() {
    return targetDuration;
  }

  public boolean isEmpty() {
    return startTime == null && endTime == null && breakDuration == null && targetDuration == null;
  }

  public void setBreakDuration(final Duration theBreakDuration) {
    breakDuration = theBreakDuration;
  }

  public void setEndTime(final Date theEndTime) {
    endTime = theEndTime;
  }

  public void setStartTime(final Date theStartTime) {
    startTime = theStartTime;
  }

  public void setTargetDuration(final Duration theTargetDuration) {
    targetDuration = theTargetDuration;
  }
}
